<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    html, body {
      width: 100%;
      height: 100%;
    }
    #container {
      width: 800px;
      height: 800px;
    }
  </style>
</head>
<body>
  <div id="container"></div>
  <script src="//lib.baomitu.com/d3/4.10.2/d3.js"></script>
  <script src="https://lib.baomitu.com/spritejs/3.7.22/spritejs.js"></script>
  <script>
    const {Scene, Sprite} = spritejs;
    const container = document.getElementById('container');
    const scene = new Scene({
      container,
      width: 800,
      height: 800,
    });

    const dataset = [125, 121, 127, 193, 309];
    const colors = ['#fe645b', '#feb050', '#c2af87', '#81b848', '#55abf8'];

    const fglayer = scene.layer('fglayer');

    const chart = d3.select(fglayer)
      .selectAll('sprite')
      .data(dataset)
      .enter()
      .append('sprite')
      .attr('x', 450)
      .attr('y', (d, i) => {
        return 200 + i * 45;
      })
      .attr('width', d => d)
      .attr('height', 40)
      .attr('bgcolor', (d, i) => colors[i]);
  </script>
</body>
</html>